<form id="edit-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action="">
    {if $pid}
    <!-- <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">上級地區:</label>
        <div class="col-xs-12 col-sm-8">
            <select data-rule="required" id="pid"  data-source="unit/index" class="form-control selectpicker" name="row[pid]">
                {foreach name="parent_list" item="vo"}
                <option value="{$vo['id']}" {if $row['pid']==$vo['id']}selected{/if}>{$vo['name']}</option>
                {/foreach}
            </select>
        </div>
    </div> -->
    {/if}

    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2"><a style="color: red">*</a>地區名:</label>
        <div class="col-xs-12 col-sm-8">
            <input id="c-name" class="form-control" name="row[name]" data-rule="required;length(~10)" type="text" value="{$row.name|htmlentities}">
        </div>
    </div>
   
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2"><a style="color: red">*</a>{:__('Weigh')}:</label>
        <div class="col-xs-12 col-sm-8">
            <input id="c-weigh" data-rule="required" class="form-control" name="row[weigh]" placeholder="請輸入排序" type="number" value="{$row.weigh|htmlentities}">
        </div>
    </div>
    <div class="form-group layer-footer">
        <label class="control-label col-xs-12 col-sm-2"></label>
        <div class="col-xs-12 col-sm-8">
            <!-- <button type="submit" class="btn btn-success btn-embossed disabled">{:__('OK')}</button> -->
            <button type="button" class="btn btn-success btn-embossed" onclick="submitThis(this,1)">{:__('OK')}</button>
            <!-- <button type="reset" class="btn btn-default btn-embossed">{:__('Reset')}</button> -->
        </div>
    </div>
</form>
<script type="text/javascript">
var old_pid = {$row['pid']};
function submitThis(obj,type) {
    var pid = $("#pid").val();
    var alert_msg = '確認提交嗎';
    if ( old_pid ) {

        if ( old_pid != pid ) {
            alert_msg = '更改了上級地區，是否確認更改，確認則會將系統相關數據的區域也做遷移'
        }
    
    }
    var that = $(obj);
    Layer.confirm(alert_msg, {
          btn: ['確認','取消'] //按鈕
    }, function(){
      $("#status_h").val(type);
      if ( type == 2 && $("#c-remarks").val() == '' ) {
        Layer.alert('請填寫不通過備註');
        return true;
      }
      $(that).closest("form").trigger("submit");
      return true;
    }, function(){
      return true;
    });
}
</script>